# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def feed_icon_tag( *args )
    image_tag( 'rss.png' )
  end

  # surrounds text in a span w/ class="value"
  def value(text)
    '<span class="value">' + text + '</span>'
  end

  def time_ago_value(text)
    time_ago_in_words(text).gsub( /(\d+)/, '<span class="value">\1</span>' ) + ' ago'
  end

  # Converts text to HTML using MediaWiki syntax
  def wiki(text)
    unless text.nil? or text.empty?
      MediaCloth::wiki_to_html(text)
    else
      ""
    end
  rescue # if the parse fails, just return the text
    text
  end

  # Savage beast says that the current_user method needs to be implemented
  # in the application controller:
  #
  # http://www.williambharding.com/blog/rails/savage-beast-20/ , step # 7
  #
  # But some/all actions were unable to find the current_user method
  # (specifically topics/new), so I added a quick helper here.
  #
  # FIXME: this method is duplicated in application_controller.rb and
  # application_helper.rb
  def current_user
    @current_user
  end

  # FIXME: this method is duplicated in application_controller.rb and
  # application_helper.rb
  # FIXME: Add logic to this method
  def login_required
    false
  end
  
  # FIXME: this method is duplicated in application_controller.rb and
  # application_helper.rb
  # FIXME: Add logic to this method
  def authorized?
    true
  end

  # FIXME: this method is duplicated in application_controller.rb and
  # application_helper.rb
  # FIXME: Add logic to this method
  def admin?
    true
  end

  # FIXME: This method should be replaced by a login system such as the
  # login generator
  def logged_in?
    true
  end

end
